class HintedForm < ActionView::Helpers::FormBuilder
  (field_helpers - %w(check_box radio_button hidden_field)).each do |selector|
    src = <<-END_SRC
      def #{selector}(field, options = {})
        label = options[:label] || field.to_s.humanize
        hint = options[:hint] ? @template.content_tag(:span, options[:hint] + @template.content_tag(:span,"&nbsp;", :class => "hint-pointer"), :class => 'hint') : ''
        @template.content_tag(:p,
            @template.content_tag(:label, "\#{label} ", :for => "\#{@object_name}_\#{field}") + 
            hint + "<br />" +
          super)
      end
    END_SRC
    class_eval src, __FILE__, __LINE__
  end
  
  %w(check_box radio_button).each do |selector|
    src = <<-END_SRC
      def #{selector}(field, options = {})
        label = options[:label] || field.to_s.humanize
        @template.content_tag(:p, super +
            @template.content_tag(:label, "\#{label} ", :for => "\#{@object_name}_\#{field}") 
          )
      end
    END_SRC
    class_eval src, __FILE__, __LINE__
  end
end